﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Global Configuration settings for Application
/// </summary>
public static class Config
{
    public static string DOMAIN()
    {
        /* Source Attribution:
         * http://devio.wordpress.com/2009/10/19/get-absolut-url-of-asp-net-application/
         */

        string path = string.Empty;

        //Getting the current context of HTTP request
        var context = HttpContext.Current;

        //Checking the current context content
        if (context != null)
        {
            //Formatting the fully qualified website url/name
            path = string.Format("{0}://{1}{2}{3}",
                                    context.Request.Url.Scheme,
                                    context.Request.Url.Host,
                                    context.Request.Url.Port == 80
                                        ? string.Empty
                                        : ":" + context.Request.Url.Port,
                                    context.Request.ApplicationPath);
        }

        if (!path.EndsWith("/"))
            path += "/";

        return path;
    }
}